package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Ckqsqdj;
import vip.xiaonuo.smzq.modular.kcl.service.ICkqsqdjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 采矿权申请登记基本信息
 *
 * @author sqq
 * @since 2024-03-19
 */
@Api(tags = "采矿权申请登记基本信息")
@RestController
@RequestMapping("/kcl/ckqsqdj")
@Validated
public class CkqsqdjController {

    @Resource
    private ICkqsqdjService iCkqsqdjService;

    /**
     * 添加采矿权申请登记基本信息
     */
    @ApiOperation("添加采矿权申请登记基本信息")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Ckqsqdj ckqsqdj) {
        iCkqsqdjService.save(ckqsqdj);
        return CommonResult.ok();
    }

    /**
     * 删除采矿权申请登记基本信息
     */
    @ApiOperation("删除采矿权申请登记基本信息")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iCkqsqdjService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑采矿权申请登记基本信息
     */
    @ApiOperation("编辑采矿权申请登记基本信息")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Ckqsqdj ckqsqdj) {
        iCkqsqdjService.updateById(ckqsqdj);
        return CommonResult.ok();
    }

    /**
     * 采矿权申请登记基本信息分页查询
     */
    @ApiOperation("采矿权申请登记基本信息分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Ckqsqdj>> page() {
        return CommonResult.data(iCkqsqdjService.page(new Ckqsqdj()));
    }
    /**
     * 采矿权申请登记基本信息
     */
    @ApiOperation("采矿权申请登记基本信息")
    @GetMapping("/getCkqsqdj")
    public CommonResult<Ckqsqdj> getCkqsqdj(
            @ApiParam(name = "nd", value = "年度",  required = true) @RequestParam Integer nd,
            @ApiParam(name = "kqbm", value = "矿区编码",  required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码",  required = true) @RequestParam Integer djflbm
    ) {
        return CommonResult.data(iCkqsqdjService.getCkqsqdj(nd, kqbm, djflbm));
    }
}
